package CContext;

sub new {
	my ($class, $parent) = @_;
	
	my $self = {
		namespace => "",
		class => undef,
		parent => $parent,
		visibleScope => 1
	};
	
	bless $self, $class;
	
	return $self;
}

sub setNamespace {
	my($this, $nm) = @_;
	$this->{namespace} = $nm;
}

sub setClass {
	my($this, $class) = @_;
	$this->{class}  = $class;
}

sub setVisibleScope {
	my $this = shift;
	$this->{visibleScope} = shift;
}

sub visibleScope {
	return (shift)->{visibleScope};
}

sub classContext {
	my $this = shift;
	
	while ($this) {
		if ($this->{class}) {
			return $this->{class};
		}	
		
		$this = $this->{parent};
	}
	
	return 0;
}

sub fullNamespace {
	my $this = shift;
	
	my @namespaces = ();
	while ($this) {
		if ($this->{namespace}) {
			push(@namespaces, $this->{namespace});
		}
		
		$this = $this->{parent};
	}

	return reverse(@namespaces);	
}

1;